import {getToken} from '@/api/api.js';
const state = {
    name:'yh',
    age:18,
	token:[],
}

const actions ={
    changeName({commit},data){
		// console.log('异步值',data)
        commit('setName',data)
		return data+'hahah';
    },
	getName:async ({commit,state})=>{
	    console.log('获取值',state.name)
		return state.name
	},
	// 获取token
	get_Token:async ({commit,state},data)=>{
		console.log('获取token值',data,state)
		let result=  await getToken(data);
		commit('setToken',result.data.data)
		// state.token  = result.data.data
		return state.token;
	}
}
// 不支持return
const mutations ={
	setToken:(state,data)=> state.token = data,
   
    setName:(state,name)=>{
        state.name = name;
        console.log(`updata name is ${state.name}`)
    }
}   
export default {
    namespaced: true,
    state,
    actions,
    mutations
}